from django.shortcuts import render

# Create your views here.
from rest_framework.generics import CreateAPIView, ListAPIView, UpdateAPIView, GenericAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from experience.models import Experience
from experience.serializers import ExperienceSerializer


class ExperienceView(CreateAPIView):
    # 需要实现经历的编辑，查询
    permission_classes = [IsAuthenticated]
    serializer_class = ExperienceSerializer


class ExperienceView1(GenericAPIView):
    permission_classes = [IsAuthenticated]
    serializer_class = ExperienceSerializer

    def get(self, request):
        id = self.request.query_params["id"]
        experience = Experience.objects.get(id=id)
        serializer = self.get_serializer(experience)
        return Response(serializer.data)
